home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Samples / Mod / Ex0 (.txt) next >
Encoding:
Oberon Document  |  1994-06-07  |  6.1 KB  |  76 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. Geneva
  17. Geneva
  18. L Frutiger Light
  19. Geneva
  20. TextRulers.StdRulerDesc
  21. TextRulers.RulerDesc
  22. TextRulers.StdStyleDesc
  23. TextRulers.StyleDesc
  24. TextRulers.AttributesDesc
  25. MODULE SamplesEx0;
  26.     IMPORT Out;
  27.     PROCEDURE Do*;
  28.     BEGIN
  29.         Out.String("Hello World"); Out.Ln    (* write string and 0DX into log *)
  30.     END Do;
  31. END SamplesEx0.
  32. TextControllers.StdCtrlDesc
  33. TextControllers.ControllerDesc
  34. Containers.ControllerDesc
  35. Controllers.ControllerDesc
  36. Geneva
  37. DevCommanders.StdViewDesc
  38. DevCommanders.ViewDesc
  39. Example 0
  40. After you have started Oberon/F, you can open the file Ex0 in the Samples folder. It contains exactly the text you are now reading.
  41. A first example of an Oberon module is given below, as an embedded text object:
  42. To compile this module, it must first be focused (i.e. set the caret or selection in it). This is done by clicking somewhere in the object. Then execute the Compile command in the Dev menu. After the compilation, a message like
  43. compiling "SamplesEx0"
  44.   new symbol file   96   0
  45. appears in the Log window. It means that module SamplesEx0 has been compiled successfully, that a code file has been written to disk containing the compiled code, that this module has a code size of 96 bytes and global variables of 0 bytes size, and that information about the module's interface has been written to disk in a symbol file. New symbol files are created whenever a module is compiled for the first time, or when its interface has changed.
  46. The interface of the above module consists of one exported procedure: SamplesEx0.Do. In order to call this procedure, a commander can be used (the little button below):
  47.  SamplesEx0.Do
  48. Click on this button to cause the following actions to occur: the code for SamplesEx0 is loaded into memory, and then its procedure Do is executed. You see the result in the log window:
  49. Hello World
  50. When you click on the button again, Oberon executes the command immediately, without loading the module's code again: once loaded, modules remain loaded unless they are explicitly removed.
  51. When clicked, a commander takes the string which follows it, and tries to interpret it as an Oberon command, i.e. as a module name followed by a dot, followed by the name of an exported, parameterless procedure.
  52. Try out the following examples:
  53.  DevCmds.ClearLog    
  54.  Dialog.Beep     
  55.  DevDebug.ShowLoadedModules
  56. The list of loaded modules can be inspected by executing the Loaded
  57. Modules command in the Info menu, or by simply clicking in the appropriate commander above. It will generate a text similar to the following:
  58. module name    bytes used    clients    compiled    loaded
  59. SamplesEx0    
  60. 0    25.10.1994  20:07:08    25.10.1994  20:08:42
  61. 1    24.10.1994  13:53:49    25.10.1994  20:08:42
  62. Config    
  63. 0    24.10.1994  13:53:47    25.10.1994  18:31:52
  64. A module can be unloaded if its client count is zero, i.e. if it is imported by no other modules. In order to unload SamplesEx0, focus the sample module again and then execute Unload in the Dev menu. The following message will appear in the log window:
  65. unload modules:
  66.     SamplesEx0
  67. When you generate the list of loaded modules again, it will look as follows:
  68. module name    bytes used    clients         compiled         loaded
  69. 0    24.10.1994  13:53:49    25.10.1994  20:08:42
  70. Config    
  71. 0    24.10.1994  13:53:47    25.10.1994  18:31:52
  72. Note that a module list is just a text which shows a snapshot of the loader state at a given point in time, it won't be updated when you load or unload modules. You can print the text, save it in a file, or edit it without danger that it may be changed by the system.
  73. In this first example, we have seen how a very simple Oberon module looks like, how it can be compiled, how its command can be executed, how commanders are used as convenient alternatives to menu entries during development, how the list of loaded modules can be inspected, and how a loaded module can be unloaded again.
  74. Geneva
  75. Documents.ControllerDesc
  76.